package com.aspirecn.core.task;

import java.util.TimerTask;

import com.aspirecn.core.datacache.*;
import com.aspirecn.core.datacache.useragent.*;

import org.apache.log4j.Logger;

/**
 * 初始化本地缓存的方法，1分钟运行一次，文件未变化不会真正reload
 * 
 * @author wangxinning
 * 
 */
public class RefreshCache extends TimerTask {

	public final static Logger logger = Logger.getLogger(RefreshCache.class);

	private GEOCache geoCache = GEOCache.getInstance();
	private IPGatewayCache ipGatewayCache = IPGatewayCache.getInstance();
	private IPRangeCache ipRangeCache = IPRangeCache.getInstance();
	private XssCache xssCache = XssCache.getInstance();
	private UACache uaCache = UACache.getInstance();
	private ShareCommonCache shareCommonCache = ShareCommonCache.getInstance();
	private HaoduanCache haoduanCache = HaoduanCache.getInstance();	
	private HolidayCache holidayCache = HolidayCache.getInstance();
	private StockCache stockCache = StockCache.getInstance();
	private ImageQuestionCache imageQuestionCache = ImageQuestionCache.getInstance();
	
	private MMDeviceIDCache mmDeviceIDCache = MMDeviceIDCache.getInstance();
	private DeviceKeywordCache deviceKeywordCache = DeviceKeywordCache.getInstance();
	private DeviceBrandCache deviceBrandCache = DeviceBrandCache.getInstance();
	private DeviceCache deviceCache = DeviceCache.getInstance();
	private DeviceGWUACache deviceGWUACache = DeviceGWUACache.getInstance();
	private DeviceOSCache deviceOSCache = DeviceOSCache.getInstance();
	private DeviceUACache deviceUACache = DeviceUACache.getInstance();
	
	

	public void run() {
		
		long start = System.currentTimeMillis();
		logger.info("开始刷新sharecommon缓存*************************");
		shareCommonCache.reload();
		geoCache.reload();
		ipGatewayCache.reload();
		ipRangeCache.reload();
		xssCache.reload();
		uaCache.reload();
		haoduanCache.reload();
		holidayCache.reload();
		stockCache.reload();
		imageQuestionCache.reload();
		
		//新版UA
		mmDeviceIDCache.reload();//首先是mm，其余都要load
		deviceKeywordCache.reload();//会用到上面的缓存
		deviceBrandCache.reload();
		deviceCache.reload();//会用到mmDeviceIDCache缓存
		deviceGWUACache.reload();
		deviceOSCache.reload();
		deviceUACache.reload();
		
		long end = System.currentTimeMillis();
		logger.info("结束sharecommon缓存刷新*************************" + (end-start) + "ms!");
	}
}